#include "geometryinfo.h"

#define ZERO "0.00"

GeometryInfo::GeometryInfo(QWidget *parent)
    : QWidget(parent)
{
    initUI();
    setLineEditState(false);
}

#include <QGridLayout>
void GeometryInfo::initUI()
{
    QGridLayout *pGridLayout = new QGridLayout();

    QLabel *plabelHighInfo = new QLabel("高度信息", this);
    pGridLayout->addWidget(plabelHighInfo, 0, 0);

    QLabel *plabelHigh = new QLabel("高度[m]:", this);
    m_pLineEdit_High = new QLineEdit(ZERO, this);
    pGridLayout->addWidget(plabelHigh, 1, 0, 1, 1, Qt::AlignRight);
    pGridLayout->addWidget(m_pLineEdit_High, 1, 1);

    QLabel *plabelHighA = new QLabel("a:", this);
    QLabel *plabelHighB = new QLabel("b:", this);
    QLabel *plabelHighC = new QLabel("c:", this);
    QLabel *plabelHighD = new QLabel("d:", this);
    m_pLineEdit_HighA = new QLineEdit(this);
    m_pLineEdit_HighB = new QLineEdit(this);
    m_pLineEdit_HighC = new QLineEdit(this);
    m_pLineEdit_HighD = new QLineEdit(this);

    pGridLayout->addWidget(plabelHighA, 2, 0, 1, 1, Qt::AlignRight);;
    pGridLayout->addWidget(m_pLineEdit_HighA, 2, 1);
    pGridLayout->addWidget(plabelHighB, 2, 2, 1, 1, Qt::AlignRight);;
    pGridLayout->addWidget(m_pLineEdit_HighB, 2, 3);
    pGridLayout->addWidget(plabelHighC, 3, 0, 1, 1, Qt::AlignRight);;
    pGridLayout->addWidget(m_pLineEdit_HighC, 3, 1);
    pGridLayout->addWidget(plabelHighD, 3, 2, 1, 1, Qt::AlignRight);;
    pGridLayout->addWidget(m_pLineEdit_HighD, 3, 3);

    QLabel *plabelRadianInfo = new QLabel("弧度信息", this);
    pGridLayout->addWidget(plabelRadianInfo, 4, 0);

    QLabel *plabelRadian = new QLabel("弧度[°]:", this);
    m_pLineEdit_Radian = new QLineEdit(ZERO, this);
    pGridLayout->addWidget(plabelRadian, 5, 0, 1, 1, Qt::AlignRight);
    pGridLayout->addWidget(m_pLineEdit_Radian, 5, 1);

    QLabel *plabelRadianA = new QLabel("a:", this);
    QLabel *plabelRadianB = new QLabel("b:", this);
    QLabel *plabelRadianC = new QLabel("c:", this);
    QLabel *plabelRadianD = new QLabel("d:", this);
    m_pLineEdit_RadianA = new QLineEdit(this);
    m_pLineEdit_RadianB = new QLineEdit(this);
    m_pLineEdit_RadianC = new QLineEdit(this);
    m_pLineEdit_RadianD = new QLineEdit(this);

    pGridLayout->addWidget(plabelRadianA, 6, 0, 1, 1, Qt::AlignRight);;
    pGridLayout->addWidget(m_pLineEdit_RadianA, 6, 1);
    pGridLayout->addWidget(plabelRadianB, 6, 2, 1, 1, Qt::AlignRight);;
    pGridLayout->addWidget(m_pLineEdit_RadianB, 6, 3);
    pGridLayout->addWidget(plabelRadianC, 7, 0, 1, 1, Qt::AlignRight);;
    pGridLayout->addWidget(m_pLineEdit_RadianC, 7, 1);
    pGridLayout->addWidget(plabelRadianD, 7, 2, 1, 1, Qt::AlignRight);;
    pGridLayout->addWidget(m_pLineEdit_RadianD, 7, 3);

    QLabel *plabelTransectionInfo = new QLabel("横切面信息", this);
    pGridLayout->addWidget(plabelTransectionInfo, 8, 0);

    QLabel *plabelGradient = new QLabel("倾斜度[°]:", this);
    m_pLineEdit_Gradient = new QLineEdit(ZERO, this);
    pGridLayout->addWidget(plabelGradient, 9, 0, 1, 1, Qt::AlignRight);
    pGridLayout->addWidget(m_pLineEdit_Gradient, 9, 1);

    setLayout(pGridLayout);
}

void GeometryInfo::setLineEditState(bool bState)
{
    m_pLineEdit_High->setEnabled(bState);
    m_pLineEdit_HighA->setEnabled(bState);
    m_pLineEdit_HighB->setEnabled(bState);
    m_pLineEdit_HighC->setEnabled(bState);
    m_pLineEdit_HighD->setEnabled(bState);


    m_pLineEdit_Radian->setEnabled(bState);
    m_pLineEdit_RadianA->setEnabled(bState);
    m_pLineEdit_RadianB->setEnabled(bState);
    m_pLineEdit_RadianC->setEnabled(bState);
    m_pLineEdit_RadianD->setEnabled(bState);

    m_pLineEdit_Gradient->setEnabled(bState);
}
